// 地图位置实体模型
class MapLocationEntity {
  final String locationId;
  final String userId; // 用户ID
  final String locationImage; // 位置图片URL
  final double positionX; // X轴位置 (0.0 - 1.0)
  final double positionY; // Y轴位置 (0.0 - 1.0)
  final DateTime createdTime;

  const MapLocationEntity({
    required this.locationId,
    required this.userId,
    required this.locationImage,
    required this.positionX,
    required this.positionY,
    required this.createdTime,
  });

  factory MapLocationEntity.fromJson(Map<String, dynamic> json) {
    return MapLocationEntity(
      locationId: json['locationId'] as String,
      userId: json['userId'] as String,
      locationImage: json['locationImage'] as String,
      positionX: (json['positionX'] as num).toDouble(),
      positionY: (json['positionY'] as num).toDouble(),
      createdTime: DateTime.parse(json['createdTime'] as String),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'locationId': locationId,
      'userId': userId,
      'locationImage': locationImage,
      'positionX': positionX,
      'positionY': positionY,
      'createdTime': createdTime.toIso8601String(),
    };
  }

  MapLocationEntity copyWith({
    String? locationId,
    String? userId,
    String? locationImage,
    double? positionX,
    double? positionY,
    DateTime? createdTime,
  }) {
    return MapLocationEntity(
      locationId: locationId ?? this.locationId,
      userId: userId ?? this.userId,
      locationImage: locationImage ?? this.locationImage,
      positionX: positionX ?? this.positionX,
      positionY: positionY ?? this.positionY,
      createdTime: createdTime ?? this.createdTime,
    );
  }
}
